<!DOCTYPE html>
<html>
  <head>
    <title>注册页面1</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0">
    <meta name="format-detection" content="telephone=no" />
    <link rel='stylesheet' href='stylesheets/register.css' />
    <link rel="stylesheet" href="stylesheets/dataCss/normalize3.0.2.min.css"  />
    <link rel="stylesheet" href="stylesheets/dataCss/mobiscroll.css"  />
    <link rel="stylesheet" href="stylesheets/dataCss/mobiscroll_date.css"  />
  </head>
  <body>
    <div class="container">
      <div class="content">
        <img src="images/reBg1.png" alt="" />
        <div class="title">
          <img src="images/reTitle.png" alt="" />
        </div>
        <p>基本信息</p>
        <div class="baseInfo">
          <input type="text" name="name" class="name" id="name">
          <div class="photoBox">
            <form action="api/uploadImg" method="post" enctype="multipart/form-data" class="uploadImg">
              <input type="file" name="photo" id="photo"  multiple='mutiple'>
              <input type="hidden" name="hId" value="" class="hId">
              <i class="upload">点击这里上传文件</i>
            </form>
          </div>
          <input type="text" name="sex" class="sex" id="sex"><span></span>
          <input type="text" name="birth" class="birth" id="birth"><span class="Larrow"></span>
        </div>
        <p class="contactWay">联系方式</p>
        <div class="wayInfo">
          <input type="text" name="number" class="number" id="number">
          <input type="text" name="email" class="email" id="email">
          <input type="text" name="address" class="address" id="address">
        </div>
        <a href="rule" class="left nextBtn">
          <img src="images/left.png" alt="" />
        </a>
        <button class="nextBtn right">
          <img src="images/right.png" alt="" />
        </button>
      </div>
      <p class="tip">本活动最终解释权归乐可旅行所有</p>
    </div>
    <div class="hidde">
      <div class="hiddeContent"></div>
      <div class="sexChoose">
        <p class="man">男</p>
        <p class="woman">女</p>
      </div>
    </div>
  </body>
  <script type="text/javascript" src="http://libs.baidu.com/jquery/1.9.1/jquery.js"></script>
  <script src="/javascripts/upload.js"></script>
  <script src="/javascripts/dataControl/jquery.min.js"></script>
  <script src="/javascripts/dataControl/mobiscroll_date.js" charset="gb2312"></script>
  <script src="/javascripts/dataControl/mobiscroll.js"></script>
  <script type="text/javascript">
  $(document).ready(function(){
    $('.right').on('click',function() {
      var name=$('#name').val();
      var sex=$('#sex').val();
      var birth=$('#birth').val();
      var number=$('#number').val();
      var email=$('#email').val();
      var address=$('#address').val();
      if(name==null||name==''){
        alert('姓名不能为空');
        return 0;
      }
      if(sex==null||sex==''){
        alert('性别不能为空');
        return 0;
      }
      if(birth==null||birth==''){
        alert('出生时间不能为空');
        return 0;
      }
      if(number==null||number==''){
        alert('手机号码不能为空');
        return 0;
      }
      if(email==null||email==''){
        alert('邮箱不能为空');
        return 0;
      }
      if(address==null||address==''){
        alert('收件地址不能为空');
        return 0;
      }
      $.ajax({
        type:'post',
        url:'api/baseInfo',
        data:{
          name:name,
          sex:sex,
          birth:birth,
          number:number,
          email:email,
          address:address
        },
        dataType:'json',
        success:function (data) {
           console.log(data.id);
           if(data.id!=null && data.id!=''){
             var id = data.id;
             if( $('#photo').val()!=null && $('#photo').val()!=''){
               $('.hId').val(data.id);
               console.log('hId:'+$('.hId').val());
               $('.uploadImg').submit();
             }else {
               window.location.href="register2?id=data.id";
             }
           }
        }
      });
    });
  });

  $('#sex').bind('click',function() {
    $('.hidde').css('display','block');
    $('.man').bind('click',function() {
      var $content=$('.man').text();
      $("#sex").attr("value",$content);
      $('.hidde').css('display','none');
    });
    $('.woman').bind('click',function() {
      var $content=$('.woman').text();
      $("#sex").attr("value",$content);
      $('.hidde').css('display','none');
    })
  })

  $(function () {
  	var currYear = (new Date()).getFullYear();
  	var opt={};
  	opt.date = {preset : 'date'};
  	opt.datetime = {preset : 'datetime'};
  	opt.time = {preset : 'time'};
  	opt.default = {
  		theme: 'android-ics light', //皮肤样式
  		display: 'bottom', //显示方式
  		mode: 'scroller', //日期选择模式
  		dateFormat: 'yyyy-mm-dd',
  		lang: 'zh',
  		showNow: true,
  		nowText: "今天",
  		startYear: currYear - 50, //开始年份
  		endYear: currYear + 10 //结束年份
  	};
  	$("#birth").mobiscroll($.extend(opt['date'], opt['default']));
  });
  </script>
</html>
